﻿//using System;
//using System.Collections.Generic;
//using System.Linq;
//using System.Net;
//using System.Windows;
//using System.Windows.Controls;
//using System.Windows.Documents;
//using System.Windows.Input;
//using System.Windows.Media;
//using System.Windows.Media.Animation;
//using System.Windows.Shapes;
//using System.IO;
//using System.Collections.ObjectModel;
//using System.Threading;
//using Microsoft.Phone.Shell;

//using Microsoft.Phone.Notification;
//using Microsoft.Phone.Controls;

//namespace GeoFinderWP7
//{
//  public partial class ClientPage : PhoneApplicationPage
//  {
//    PushContext context = null;
//    private readonly ObservableCollection<string> _rawMessages = new ObservableCollection<string>();

//    public ClientPage()
//    {
//      InitializeComponent();
//    }

//    public ClientPage(PushContext push_context)
//    {
//      context = push_context;
//      InitializeComponent();
//      Loaded += ClientPage_Loaded;
//      Unloaded += ClientPage_Unloaded;
//    }

//    private void ClientPage_Unloaded(object sender, RoutedEventArgs e)
//    {
//      UnregisterRawNotification();
//    }

//    private void ClientPage_Loaded(object sender, RoutedEventArgs e)
//    {
//      RegisterRawNotification();
//    }
//    private void RegisterRawNotification()
//    {
//      var context = PushContext.Current;
//      if (context != null)
//      {
//        context.RawNotification += context_RawNotification;
//      }
//    }

//    private void UnregisterRawNotification()
//    {
//      var context = PushContext.Current;
//      if (context != null)
//      {
//        context.RawNotification -= context_RawNotification;
//      }
//    }

//    private void context_RawNotification(object sender, HttpNotificationEventArgs e)
//    {
//      try
//      {
//        using (var stream = new StreamReader(e.Notification.Body))
//        {
//          var reader = new StreamReader(e.Notification.Body);
//          var message = reader.ReadToEnd();
//          //Debug.WriteLine(string.Format("Raw notification received: {0}", message));
//          lblMessage.Text = "Raw Message Received";
//          txtMessage.Text = message;
//          reader.Close();
//        }
//      }
//      catch (Exception ex)
//      {
//        ex.Show();
//      }
//    }

//    private void button1_Click(object sender, RoutedEventArgs e)
//    {
//      Application.Current.RootVisual = new PushSettings(this, context);
//    }

//  }
//}